//
//  cellOfSinglePage.m
//  mintHome
//
//  Created by 朱彦名 on 16/6/16.
//  Copyright © 2016年 朱彦名. All rights reserved.
//

#import "cellOfSinglePage.h"
#import <Masonry.h>



@implementation cellOfSinglePage

-(void)dealloc{
    [_imageOfSingle release];
    [_labelOfMid release];
    [_labelOfLeft release];
    [_labelOfRight release];
    [super dealloc];

}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {

        [self creatViewOfCell];
        
    }
    return self;
}

- (void)creatViewOfCell{

    /** 图片  */
    self.imageOfSingle = [[UIImageView alloc]init];
    [self.contentView addSubview:self.imageOfSingle];
    self.imageOfSingle.backgroundColor = [UIColor blueColor];

    
    /** title  */
    self.labelOfMid = [[UILabel alloc]init];
    [self.contentView addSubview:self.labelOfMid];
    //self.labelOfMid.backgroundColor = [UIColor cyanColor];

    
    /** left label  */
    self.labelOfLeft = [[UILabel alloc]init];
    [self.contentView addSubview:self.labelOfLeft];
    //self.labelOfLeft.backgroundColor = [UIColor redColor];

    
    
    /** right label  */
    self.labelOfRight = [[UILabel alloc]init];
    [self.contentView addSubview:self.labelOfRight];
    //self.labelOfRight.backgroundColor = [UIColor orangeColor];

}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{

    [_imageOfSingle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo (self.contentView.mas_top).with.offset(0);
       
        make.left.equalTo (self.contentView.mas_left).with.offset (0);
        
        make.height.mas_equalTo (self.contentView.bounds.size.height * 2 / 3 + 20);
        
        make.width.mas_equalTo (self.contentView.bounds.size.width) ;
    }];
    
    [self.labelOfMid mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo (self.imageOfSingle.mas_bottom).with.offset (5);
        
        make.left.equalTo (self.contentView.mas_left).with.offset (5);
        
        make.width.mas_equalTo (self.contentView.bounds.size.width - 10);
        
        make.height.mas_equalTo (self.contentView.bounds.size.height  / 5 - 20);
    }];
    
    [self.labelOfLeft mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo (self.labelOfMid.mas_bottom).with.offset (10);
        
        make.left.equalTo (self.contentView.mas_left).with.offset (10);
        
        make.width.mas_equalTo (self.contentView.bounds.size.width /3);
        
        make.height.mas_equalTo (self.contentView.bounds.size.height / 5 - 30);
    }];
    
    [self.labelOfRight mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo (self.labelOfMid.mas_bottom).with.offset (10);
        
        
        make.right.equalTo (self.contentView.mas_right).with.offset (10);
        
        make.width.mas_equalTo (self.contentView.bounds.size.width / 3 +5 );
        
        make.height.mas_equalTo (self.contentView.bounds.size.height / 5 - 30);
    }];
}
- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    return layoutAttributes;
}
- (void)layoutSubviews{
    
    [super layoutSubviews];
}

@end
